import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { cardDescriptionDefaultProps } from './defaultProps';
import type { CardDescriptionOptions } from './type';

export interface CardDescriptionProps extends CardDescriptionOptions, HTMLAttributes<HTMLDivElement> {}

const CardDescription: FC<CardDescriptionProps> = (props) => {
  const { className, aligned, children, forwardedRef, ...cardDescriptionProps } = props;

  return createElement(
    'div',
    {
      ref: forwardedRef,
      className: classNames(aligned, { aligned }, 'description', className),
      ...cardDescriptionProps,
    },
    children,
  );
};

CardDescription.displayName = 'CardDescription';
CardDescription.defaultProps = cardDescriptionDefaultProps;

export default CardDescription;
